Repository navigation
Fix paywall Add payment card CTA navigation race in restricted action - #91509
neil-marcellini merged 13 commits into
Conversation
Use dismissModal with afterTransition for web/native owner CTA to avoid modal-stack race, and add regression tests for web and native routes.
|
@thelullabyy Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9aa78e5b2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| Navigation.dismissModal({ | ||
| afterTransition: () => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD), |
There was a problem hiding this comment.
Preserve underlying RHP flow before navigating to billing
Switching from Navigation.closeRHPFlow() to Navigation.dismissModal() changes behavior from “pop only the top RHP flow” to “pop the entire RIGHT_MODAL navigator,” so users who open this paywall from a multi-step modal flow (e.g., expense creation) lose their in-progress stack when they tap the CTA. closeRHPFlow was designed to keep prior RHP routes when more than one exists, but dismissModal always dismisses the modal route itself, so back navigation can no longer return to the interrupted flow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
agreed, this is better, Preserves underlying multi-step RHP flow semantics ( closeRHPFlow ) , Still avoids the navigation race ( waitForTransition ), code updated.
Use closeRHPFlow with waitForTransition navigation for web/native owner CTAs to avoid modal-stack race without dismissing the full modal stack, and add regression tests.
|
okay @codex review again, make no mistakes |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-06-09.at.16.36.23.mov |
| const expensifyIcons = useMemoizedLazyExpensifyIcons(['Unlock']); | ||
|
|
||
| const addPaymentCard = () => { | ||
| const addPaymentCard = useCallback(() => { |
There was a problem hiding this comment.
Why do we need to wrap this func inside useCallback? I believe it will be handled by react compiler, we should avoid using useCallback and useMemo
|
It looks like the solution you are using here doesn't match with your proposal, any reason behind? @neerajbachani |
Drop manual memoization from the restricted action CTA handlers while keeping the existing closeRHPFlow plus waitForTransition navigation behavior unchanged.
|
Yes the current implementation is slightly different from the original proposal. I initially implemented the accepted proposal exactly with To avoid that regression, I updated the implementation to:
So the root cause/fix direction is the same (serialize navigation instead of doing close + navigate in the same tick), but the implementation was refined during review to preserve existing RHP behavior. Also agreed on |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@thelullabyy friendly bump, thanks |
|
@neerajbachani Missing recordings for android, ios, android web, ios web. Please add them |
|
Did you re-test the latest changes? I think it doesn't work Screen.Recording.2026-05-29.at.11.28.56.mov |
|
@thelullabyy Thanks for re-testing The intermediate change ( codex concern was correct but not for this repro, i matters when the user should only close the top screen and return to the previous step in the same modal (e.g. pop paywall, stay in create-expense). but this issue is not our case. so I've reverted to the accepted approach: |
Revert closeRHPFlow plus waitForTransition so billing navigation runs after the full modal dismisses, matching the accepted proposal and fixing layered RHP navigation in the expense paywall flow.
|
@neerajbachani The recording for android/ios native and android mWeb are invalid. You have to use simulator/real device to test it. I see you are testing on windows' chrome. Let's update them. Besides, please note that testing on iOS and android are required steps in order to get the PR reviewed & merged |
|
For Android mWeb I used USB debugging: you can only see the Onyx injection part only show cursor on desktop because that’s where the console runs for the issue repro. After injection, the app flow in the video is on my real device. lemme know if this works or I'll re-record? |
Use dismissModal with afterTransition for web/native owner CTA to avoid modal-stack race, and add regression tests for web and native routes.
Use closeRHPFlow with waitForTransition navigation for web/native owner CTAs to avoid modal-stack race without dismissing the full modal stack, and add regression tests.
Drop manual memoization from the restricted action CTA handlers while keeping the existing closeRHPFlow plus waitForTransition navigation behavior unchanged.
Revert closeRHPFlow plus waitForTransition so billing navigation runs after the full modal dismisses, matching the accepted proposal and fixing layered RHP navigation in the expense paywall flow.
|
@neerajbachani I see. Please re-record the android and ios native then |
|
@thelullabyy I've added the native platform recordings delay happens because while reproducing on native, I initially thought something was wrong because the add payment card flow doesn't open and there's no "Add payment card" button on the Subscription page. I checked staging/live with the same account and saw the same behavior, then traced it in the codebase.
On native we intentionally route the paywall CTA to the Subscription page ( So for this issue, native QA is: paywall → foreground Subscription page (not add-card parity with web). lemme know your thoughts about this being expected or need follow up pr? |
| }, [activeRoute]); | ||
| const goToSubscription = () => { | ||
| const activeRoute = Navigation.getActiveRoute(); | ||
| Navigation.dismissModal({ |
There was a problem hiding this comment.
@thelullabyy I initially kept the native change because I thought the same paywall navigation race could happen on native too.
After repeated native testing , Go to Subscription already navigates correctly to the foreground Subscription page with the existing main native handler, so native change is not needed for this issue.
I reverted native in 18ea3ec and the latest branch keeps native unchanged (web-only fix + tests). Final PR diff only changes web index.tsx and unit tests.
|
@neerajbachani The evidence for ios native looks not real. Do you have device to test it? Please make sure that you are able and test on native device as it is required when contributing to the project @Expensify/product Could you please confirm this behavior?
Should we fix the native app to match with native web behavior or it is expected? Native Web: -2.movNative App: Screen.Recording.2026-06-04.at.02.16.24.mov |
|
That is expected behavior AFAIK. |
|
Thanks for confirmation @shawnborton All yours @neerajbachani then #91509 (comment) #91509 (comment) Please resolved these 2 issues ^ so we are good to go |
|
Yep, agreed with @shawnborton it's expected due to Apple/Google restrictions. 👍 |
Keep web dismissModal afterTransition fix only. Native was re-tested on Android without navigation changes and already redirects correctly, so restore main closeRHPFlow behavior and update tests accordingly.
|
@neerajbachani Bump on this, could you please priority this task, I think we are getting slowly on this |
Resolve conflicts by keeping local web-only dismissModal fix and unchanged native closeRHPFlow handler after device validation.
@thelullabyy aight, addressed both points:
If iOS device recording is still required for merge, please let me know, I’ll add a real-device recording as well Updated branch is pushed and ready for re-review. Thanks! |
|
On my plate today |
|
🚧 @neil-marcellini has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
Replace the unsafe `as` cast with proper type narrowing so post-merge preDeploy lint passes after PR Expensify#91509. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.4.5-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 Help site review: No documentation changes required. This PR is an internal navigation-sequencing bug fix and does not change any user-facing behavior, feature, or copy. Why no docs changes are needed
Because there are no behavioral or copy changes, no draft help site PR was created. @neerajbachani, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR (Note: no help site PR was created because this change has no documentation impact. If you believe a docs update is warranted, let me know what behavior to document and I'll draft one.) |
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.5-6 🚀
|

Use dismissModal with afterTransition for web/native owner CTA to avoid modal-stack race, and add regression tests for web and native routes.
Explanation of Change
The workspace owner paywall CTA was calling
Navigation.closeRHPFlow()and immediately callingNavigation.navigate(...). That dispatches two navigation actions in the same tick while the RHP/modal stack is still transitioning, which can drop the follow-up navigation and make the button appear to do nothing.This PR keeps the existing UX unchanged (web still shows Add payment card and routes to the add-card screen; native still shows Go to Subscription and routes to subscription settings). It only fixes navigation sequencing by using
Navigation.dismissModal({ afterTransition: () => Navigation.navigate(...) })in both platform handlers, and adds unit tests to lock in web/native behavior.Fixed Issues
$ #89718
PROPOSAL: #89718 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android-native.mp4
Android: mWeb Chrome
lv_0_20260601170213.mp4
iOS: Native
iOS: mWeb Safari
lv_0_20260601175543.mp4
MacOS: Chrome / Safari
lv_0_20260525004735.mp4